import java.io.*;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

/*
 ID: ning yusui
 LANG: JAVA
 TASK: concom
 */

public class concom {
    Scanner in;
    PrintWriter out;
    public static final int COM_SIZE = 101;
    private boolean[][] controlled;
    private int[][] controlPercent;
    private Set<Integer> companySet;
    private int[][] stockAdj;

    public concom() throws IOException {
        in = new Scanner(new File(this.getClass().getName() + ".in"));
        out = new PrintWriter(new BufferedWriter(new FileWriter(this.getClass().getName() +
                ".out")));
    }

    private void work() {
        input();

        search();

        output();
    }

    private void output() {
        for(int i: companySet){
            for(int j: companySet){
                if(i!=j && controlled[i][j]){
                     out.println(i+" "+j);
                }
            }
        }

        out.flush();
        out.close();
    }

    protected void search() {
        controlled = new boolean[COM_SIZE][COM_SIZE];
        controlPercent = new int[COM_SIZE][COM_SIZE];

        for(int i: companySet){
            searchControl(i, i);
        }
    }

    private void input() {
        int edgeCount = in.nextInt();
        stockAdj = new int[COM_SIZE][COM_SIZE];
        companySet = new TreeSet<Integer>();
        for (int i = 0; i < edgeCount; i++) {
            int x = in.nextInt();
            int y = in.nextInt();
            int percent = in.nextInt();
            stockAdj[x][y] = percent;
            companySet.add(x);
            companySet.add(y);
        }
    }

    protected void searchControl(int start, int middle) {
        for(int i: companySet){
            controlPercent[start][i] += stockAdj[middle][i];
        }
        controlled[start][middle] = true;
        for(int i: companySet){
            if(!controlled[start][i] && controlPercent[start][i]>50){
                 searchControl(start,i);
            }
        }
    }

    public static void main(String[] args) throws IOException {
        new concom().work();
    }
}
